package com.nineclock.common.oss.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.nineclock.common.oss.service.impl.OSSServiceImpl;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 该工具类的作用就是创建OSSClient实例交给spring管理
 */
@Data
@Configuration
public class OssClientUtils {
    @Autowired
    private OssProperties ossProperties;

    @Bean
    public OSS ossClient() {
        //创建OSSClient实例交给spring管理
        return new OSSClientBuilder()
                .build(ossProperties.getEndpoint(), ossProperties.getAccessKeyId(), ossProperties.getAccessKeySecret());
    }
}